import { Global, Module } from '@nestjs/common';
import { DbService } from './db.service';
import {TypegooseModule} from 'nestjs-typegoose'
import { User } from './models/user.model';
import { Episode } from './models/episode.model';
import { Course } from './models/course.model';

const models = TypegooseModule.forFeature([
  User,
  Course,
  Episode
])

@Global()
@Module({
  imports:[
      TypegooseModule.forRoot('mongodb://localhost/topfullstack',{
        useNewUrlParser:true,
        useUnifiedTopology:true,
        useCreateIndex:true,
        useFindAndModify:false,
      }),
      models
  ],
  providers: [DbService],
  exports: [DbService,models],
})
export class DbModule {}
